package com.lcp.se.controller;

import com.lcp.se.entity.data.Chat;
import com.lcp.se.entity.result.PageResultForMini;
import com.lcp.se.entity.result.Result;
import com.lcp.se.service.ChatService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 聊天消息处理
 *
 * @author lcp
 * @date 2020/8/5 21:51
 */
@RestController
@RequestMapping(path = "/user/chat")
public class ChatController {

    @Resource
    private ChatService chatService;

    /**
     * 发送聊天消息
     *
     * @param chat 消息内容
     * @return 结果
     */
    @RequestMapping(path = "/send")
    public Result<String> send(Chat chat) {
        return chatService.send(chat);
    }

    /**
     * 获取指定预约的聊天记录
     *
     * @return 结果
     */
    @RequestMapping(value = "/list")
    public Result<PageResultForMini<Chat>> list(@RequestParam(name = "appointmentId") String appointmentId,
                                                @RequestParam(name = "pageSize") Integer pageSize,
                                                @RequestParam(name = "currentPage") Integer currentPage) {
        return chatService.list(appointmentId, pageSize, currentPage);
    }

}